package com.tanhua.app.controller;


import com.tanhua.api.db.UserInfoApi;
import com.tanhua.domain.db.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.TimeUnit;


@Component
public class MyTask {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Autowired
    private UserInfoApi userInfoApi;

    @Scheduled(cron = "0 0 0 * * ?")
    public void aaa(){
        List<UserInfo> userInfos=userInfoApi.findAllUsers();
        for (UserInfo userInfo : userInfos) {
            Long userId = userInfo.getId();
            Boolean aBoolean = stringRedisTemplate.hasKey("VOICE_SURPLUS_" + userId);
            stringRedisTemplate.opsForValue().set("VOICE_SURPLUS_"+userId,"5",1, TimeUnit.DAYS);
        }
    }
}
